﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;

namespace uclock.ClockClass
{
    internal class EmailSend
    {
        public static void Send(string adress, string msg)
        {
            if (String.IsNullOrEmpty(adress) || String.IsNullOrEmpty(msg))
            {
                return;
            }

            var client = new SmtpClient("smtp.qq.com")
                {
                    UseDefaultCredentials = false,
                    Credentials = new System.Net.NetworkCredential("yuhaoo@qq.com", "z87922072"),
                    DeliveryMethod = SmtpDeliveryMethod.Network
                };

            var addressFrom = new MailAddress("yuhaoo@qq.com", "Revess");
            var addressTo = new MailAddress(adress, "");

            var message = new MailMessage(addressFrom, addressTo)
                {
                    Sender = new MailAddress("yuhaoo@qq.com"),
                    BodyEncoding = System.Text.Encoding.UTF8, 
                    IsBodyHtml = true,
                    Body = msg
                };
            client.Send(message);
        }
    }

}
